package com.tjc.chain;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: tjc
 * @description
 * @Date Created in 21:33 2022-08-03
 */
public class FilterChain {
    List<Filter> filters = new ArrayList<>();
    int index;

    public void doFilter(Object obj) {
        if (index < filters.size())
            filters.get(index++).doFilter(obj, this);
    }

    public FilterChain add(Filter filter) {
        filters.add(filter);
        return this;
    }
}
